#ifndef CPP_COMPOUND_BUTTON_H
#define CPP_COMPOUND_BUTTON_H

#include <widget/Button.h>

//@brief 复合按钮
//@author cvte
//@description
class CompoundButton : public Button {
   public:
    CompoundButton();
    virtual ~CompoundButton();

    class OnCheckedChangeListener {
       public:
        virtual void onCheckedChanged(View& view, bool isChecked);
    };

    //method 设置是否选中，会触发回调
    void setChecked(bool isChecked);
    //method 设置是否选中，如果shouldTriggerCallback为true会触发回调，否则不触发
    void setChecked(bool isChecked, bool shouldTriggerCallback);
    bool isChecked();

    void setOnCheckedChangeListener(OnCheckedChangeListener& listener);

    void toggle();

   protected:
    void onAttachedToWindow();
    void onDetachedFromWindow();

    bool mIsChecked = false;
    OnCheckedChangeListener* mOnCheckedChangeListener = nullptr;
};

#endif /* CPP_COMPOUND_BUTTON_H */